package edu.kit.aifb.lidasora.ppmModel;

import java.util.Arrays;

import edu.kit.aifb.lidasora.ppmModel.transitionCount.SimpleDecrement;


public class PPMModelTester implements Runnable{

	public static int NUMBER_OF_THREADS = 10;
	
	DataExampleCreator dec = new DataExampleCreator(127, 2000, 10);
	
	
	PPMModel<String> model;
	static long[] threadStarting = new long[NUMBER_OF_THREADS];
	
	public static void main(String[] args) {

		PPMModel<String> model = new PPMModel<String>(4, "ROOT", new SimpleDecrement());
			for (int i = 0; i < NUMBER_OF_THREADS; i++) {
				 new Thread(new PPMModelTester(i, model)).start();
				 threadStarting[i] = System.currentTimeMillis();
			}
		
	}
	
	int number;
	
	PPMModelTester(int i, PPMModel model) {
		this.number = i;
		this.model = model;
	}
	
	@Override
	public void run() {
		//try DataExampleCreator
		for(int i = 0; i< 5000; i++){
			model.learnSequence(dec.getToyData());
		}
		model.learnSequence("s","s", "c", "r", "s", "c");
		System.out.println(Arrays.toString(model.predict(new String[]{"d","e","s"})));
		
		System.out.println("Created a PPM model with " + model.getCreatedNodesNumber() + " nodes");
		System.out.println("Thread finished" +  number + "\tTime needed: " + (System.currentTimeMillis() - threadStarting[number]));
		System.out.println(model.toString());
	}
	
	

}
